#include <stdio.h>
#include <windows.h>

// 定义函数指针类型
typedef int (*is_prime_func)(const char*);

int main() {
    // 加载DLL
    HMODULE hDll = LoadLibrary("prime_check.dll");
    if (!hDll) {
        printf("无法加载DLL\n");
        return 1;
    }
    
    // 获取函数指针
    is_prime_func is_prime = (is_prime_func)GetProcAddress(hDll, "is_prime");
    if (!is_prime) {
        printf("无法找到函数\n");
        FreeLibrary(hDll);
        return 1;
    }
    
    // 测试一些数字
    const char *test_numbers[] = {
        "2", "3", "4", "17", "100", "101", 
        "1000000007", "123456789012345678901234567890123456789012345678901",
        "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999991",
        NULL
    };
    
    for (int i = 0; test_numbers[i] != NULL; i++) {
        int result = is_prime(test_numbers[i]);
        printf("%s is %s\n", test_numbers[i], 
               result == 1 ? "prime" : 
               result == 0 ? "not prime" : "invalid input");
    }
    
    // 释放DLL
    FreeLibrary(hDll);
    return 0;
}